﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title></title>
    <link href="../../static/css/font.css" rel="stylesheet" />
    <link href="../../static/css/weadmin.css" rel="stylesheet" />
    <link href="../../lib/layui/css/layui.css" rel="stylesheet" />
    <script src="../../../lib/layui/layui.js"></script>
    <style>
        .layui-tab-content {
            margin: 0 auto;
            width: 90%;
        }
    </style>
</head>
<body>
    <div class="layui-form">
        <div class="layui-card-body">
            <div class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label">总人数：</label>
                    <div class="layui-input-inline">
                        <input type="text" placeholder="" maxlength="50" class="layui-input" id="Num" name="Num" />
                    </div>

                </div>
                <div class="layui-form-item"> 
                    <table id="dataList" lay-filter="dataList"></table>
                </div>
            </div>
        </div>
    </div>
    <script>
        layui.use(['form', 'laydate', 'table', 'jquery', 'element', 'layer', 'tree', 'util'], function () {
            var $ = layui.jquery
                , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
            var table = layui.table;
            var form = layui.form;
            var layer = layui.layer;
            var TCOID = "";
            if (GetQueryString("TCOID") != null) { TCOID = GetQueryString("TCOID"); }
            //车间数据开始
            function showList() {
                var swhere = JSON.stringify({
                    TCOID: TCOID
                });
                table.render({
                    elem: '#dataList'
                    , url: ApiUrl + 'TrainCourse/GetCourseStudyCourseCount_ChengwuyuanStudyCourseRecorder'
                    , id: "dataList1"
                    , headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    }
                    //, page: true
                    , cols: [[
                        { field: 'DepName', title: '乘务员', width: 200 },
                        { field: 'flagId', title: '学习时间' }
                    ]]
                    , where: { swhere: swhere }
                    , parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    done: function (res, curr, count) {
                        //如果是异步请求数据方式，res即为你接口返回的信息。
                        //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                        if (res.data != null) {
                            var p = $(".layui-laypage-skip").find("input[type=text]").val();
                            var c = $(".layui-laypage-limits select").find("option:selected").text().substring(0, 2);
                            var k = (Number(p) - 1) * Number(c);
                            for (var i = 0; i < res.data.length; i++) {
                                var item = res.data[i];
                                var ix = item.Row - 1 - k;
                                $(".layui-table-body table tbody tr[data-index=" + ix + "]").attr("style", dataRowColor[item.TPDepLevel]);
                            }
                            $("#Num").val(res.count);
                        }

                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                    }
                });
            }
            showList();
        });
    </script>

</body>
</html>